feat: 新增 C++17 Header-only 原生实现 (Closes #1)#2
Open
mikami-w wants to merge 4 commits intomcpplibs:mainfrom
Open
feat: 新增 C++17 Header-only 原生实现 (Closes #1)#2mikami-w wants to merge 4 commits intomcpplibs:mainfrom
mikami-w wants to merge 4 commits intomcpplibs:mainfrom
Conversation
Sunrisepeak
reviewed
Jan 28, 2026
Member
There was a problem hiding this comment.
这个部分是可以复用的 直接对外提供一个 llmapi.hpp 的头文件 (只包含接口不包含实现) 即可 稍后我拆分一下, 更新上来 你再rebase
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
关联 Issue: Closes #1
修改类型
PR 详情
为了让非 C++23 环境(如 C++17 项目)也能直接使用本库,本 PR 新增了一套 Header-only 的 C++17 实现。
实现方式
这一实现并非对 C 接口的封装,而是将
src/*.cppm中的核心业务逻辑直接移植到了 C++17 标准的头文件中:代码移植:
module相关语法替换为标准的#include。concept约束替换为 C++17 兼容的模板写法。新增文件 (位于
include/下):include/llmapi.hpp: C++17 版本的统一入口。include/llmapi/openai.hpp: 对应原src/openai.cppm的逻辑。include/llmapi/url.hpp: 对应原src/url.cppm的逻辑。构建配置:
xmake.lua,将新头文件加入安装/导出列表。文档:
设计说明
src/*.cppm(C++23 Modules) 和src/c/(C ABI) 代码完全未作修改。include/llmapi.hpp并链接libcurl和nlohmann/json即可,不需要编译原来的 C++23 模块库。测试
已在本地 C++17 环境下测试通过,功能与 C++23 Modules 版本实现保持一致。